package pe.edu.sisclas.model.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import pe.edu.sisclas.model.dao.LaboratorioDao;
import pe.edu.sisclas.model.dao.exception.DaoException;
import pe.edu.sisclas.model.domain.Laboratorio;
import pe.edu.sisclas.model.service.LaboratorioService;
import pe.edu.sisclas.model.service.exception.ServiceException;

@Service("laboratorioService")
public class LaboratorioServiceImpl implements LaboratorioService {

	@Autowired
	private LaboratorioDao laboratorioDao;
	
	@Transactional(readOnly = false, rollbackFor = ServiceException.class)
	@Override
	public Laboratorio obtenerLaboratorio(String numero)
			throws ServiceException {
		try{
			Laboratorio laboratorio = laboratorioDao.getByName(numero);
			return laboratorio;
		}catch(DaoException e){
			e.printStackTrace();
			throw ServiceException.mensaje("Error al obtener Laboratorio");
		}
	}

	public LaboratorioDao getLaboratorioDao() {
		return laboratorioDao;
	}

	public void setLaboratorioDao(LaboratorioDao laboratorioDao) {
		this.laboratorioDao = laboratorioDao;
	}
	
}
